package day52.pet.controller;

import day52.pet.service.ISearchMasterMsgAuditLogService;
import day52.pet.domain.SearchMasterMsgAuditLog;
import day52.pet.query.SearchMasterMsgAuditLogQuery;
import day52.basic.util.AjaxResult;
import day52.basic.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/searchMasterMsgAuditLog")
public class SearchMasterMsgAuditLogController {
    @Autowired
    public ISearchMasterMsgAuditLogService searchMasterMsgAuditLogService;


    /**
     * 保存和修改公用的
     * @param searchMasterMsgAuditLog  传递的实体
     * @return Ajaxresult转换结果
     */
    @PutMapping
    public AjaxResult addOrUpdate(@RequestBody SearchMasterMsgAuditLog searchMasterMsgAuditLog){

        if( searchMasterMsgAuditLog.getId()!=null){
            searchMasterMsgAuditLogService.update(searchMasterMsgAuditLog);
        }else{
            searchMasterMsgAuditLogService.add(searchMasterMsgAuditLog);
        }
        return AjaxResult.me();

    }
    /**
    * 删除对象信息
    * @param id
    * @return
    */
    @DeleteMapping(value="/{id}")
    public AjaxResult delete(@PathVariable("id") Long id){
        searchMasterMsgAuditLogService.delete(id);
        return AjaxResult.me();
    }
	
    //获取用户
    @GetMapping("/{id}")
    public SearchMasterMsgAuditLog get(@PathVariable("id")Long id) {

        return searchMasterMsgAuditLogService.findOne(id);
    }


    /**
    * 查看所有的员工信息
    * @return
    */
    @GetMapping()
    public List<SearchMasterMsgAuditLog> list(){

        return searchMasterMsgAuditLogService.findAll();
    }


    /**
    * 分页查询数据
    *
    * @param query 查询对象
    * @return PageList 分页对象
    */
    @PostMapping("/list")
    public PageList<SearchMasterMsgAuditLog> json(@RequestBody SearchMasterMsgAuditLogQuery query) {

        return searchMasterMsgAuditLogService.pageQuery(query);
    }
}
